<?php
include_once('../../include/init.php'); 
$dueid = $_GET['dueid'];
$departmentid = $_GET['departmentid'];
$cid = $_GET['bval'];
$classid = $_GET['classid'];
$majorid = $_GET['majorid'];
if($departmentid !='')
{
    if($departmentid !='-1'){
        $sql="select * from nettteach_department";
        $result = mysql_query($sql);
        $list=array();
        while($row = mysql_fetch_array($result)){
             $list[]=array('id'=>$row['id'],'name'=>$row['name']);
        }
    }
    $json = json_encode($list);
    echo($json);
}
if($cid !=''){
    if($cid !='-1'){
        $sql="select * from nettteach_major where departmentid='".$cid."'";
        $result = mysql_query($sql);
        $list=array();
        while($row = mysql_fetch_array($result)){
          $list[]=array('id'=>$row['id'],'name'=>$row['name']);
        }
//        if(empty($list))
//        {
//            $list[]=array('id'=>'-1','name'=>'暂无专业');
//        }
    }

    $json = json_encode($list);
    echo($json);
}
if($classid !='' )
{
    if($cid !='-1'){
        if($dueid !=''){
            $sql="select * from nettteach_class where majorid='".$classid."' and dueid =".$dueid;
        }else{
            $sql="select * from nettteach_class where majorid='".$classid."'";
        }
        $result = mysql_query($sql);
        $list=array();
        while($row = mysql_fetch_array($result)){
          $list[]=array('id'=>$row['id'],'name'=>$row['name']);
        }
//        if(empty($list))
//        {
//             $list[]=array('id'=>'-1','name'=>'暂无班级');
//        }
    }

    $json = json_encode($list);
    echo($json);
}
if($majorid !='-1'&&$majorid !='' )
{

        $sql="select id,realname  from nettteach_member where majorid='".$majorid."' and type in(1,2) ";
        $result = mysql_query($sql);
        $list=array();
        while($row = mysql_fetch_array($result)){
          $list[]=array('id'=>$row['id'],'name'=>$row['realname']);
        }
    

    $json = json_encode($list);
    echo($json);
}
?>